package leetcode

func majorityElement(nums []int) int {
    cnt := map[int]int{}
    for _, num := range nums {
        cnt[num] ++
        if cnt[num] >= len(nums) / 2 + 1 {
            return num
        }
    }
    
    return -1
}